﻿@using Annual_faculty_promotions.Core.Enums
@using Annual_faculty_promotions.WebUI.Helpers
@model Annual_faculty_promotions.WebUI.Areas.UserArea.Models.AddRequestViewModel
@{
    var numList = Enum.GetValues(typeof(EmploymentStatus));
}

<ul class="breadcrumb breadcrumb-page">
    <li><a href="#">صفحه اصلی</a></li>
    <li class="active"><a href="#">درخواست</a></li>
</ul>

<div class="page-header">
    <div class="row">
      <div class="col-xs-12 col-sm-8">
            <div class="row">
                <hr class="visible-xs no-grid-gutter-h">
                <!-- "Create project" button, width=auto on desktops -->
                <div class="pull-left col-xs-12 col-sm-auto">
                    <a href="#" class="btn btn-danger btn-labeled" style="width: 100%;"><span class="btn-label icon fa fa-share-square-o"></span>ارسال</a>
                </div>

            </div>
        </div>
    </div>

</div>

<div class="bpanel colourable">
    <div class="bpanel-body">
        <div class="form-horizontal">
            <div class="row">
                <div class="col-sm-6">
                    <label>پایه :</label>
                    @Html.DisplayFor(p => p.Request.Grade, new { @class = "form-control input-sm", style = "color:blue" })
                </div>
                <div class="col-sm-6">
                    <label>تاریخ آخرین ترفیع :</label>
                    @ViewBag.LastDateGrade
                </div>
            </div>
            <hr />
            @using (Html.BeginForm("Create", "Request", FormMethod.Post, new { id = "addRequestForm" }))
            {
                if (Model.Request != null)
                {
                    @Html.TextBoxFor(x => x.Request.Id, new { hidden = "hidden" })
                }

                <div class="form-group">
                    <label class="col-sm-2">وضعیت استخدام :</label>
                    @foreach (object radiotext in numList)
                    {
                        if (Model.Request != null)
                        {
                            if (radiotext.ToString() == Model.Request.EmploymentStatus.ToString())
                            {
                                @Html.RadioButton("EmploymentStatus", radiotext.ToString(), true)@radiotext.ToString().Replace("_", " ")
                                <span>&nbsp;&nbsp;&nbsp;</span>
                            }
                            else
                            {
                                @Html.RadioButton("EmploymentStatus", radiotext.ToString())@radiotext.ToString().Replace("_", " ")
                                <span>&nbsp;&nbsp;&nbsp;</span>
                            }

                        }
                        else
                        {
                            @Html.RadioButton("EmploymentStatus", radiotext.ToString())@radiotext.ToString().Replace("_", " ")
                            <span>&nbsp;&nbsp;&nbsp;</span>
                        }

                    }
                </div>
                <div class="form-inline">
                    <label class="col-sm-2">گروه آموزشی :</label>
                    @if (Model.Request == null)
                    {

                        @Html.DropDownList("UnivercityStructureId",
                          (SelectList)ViewBag.Department, "", new { @class = "form-control input-sm", style = "width: 300px" })
                    }
                    else
                    {  @Html.DropDownListFor(model => model.Request.UnivercityStructureId,
                         (SelectList)ViewBag.Department, "", new { @class = "form-control input-sm", style = "width: 300px" })
                    }
                    <label>مرتبه علمی :</label>
                    @if (Model.Request == null)
                    {
                        @Html.EnumDropDownListFor(p => p.AcademicDegree, new Dictionary<string, object> { { "class", "form-control input-sm" } })
                    }
                    else
                    {
                        @Html.EnumDropDownListFor(p => p.Request.AcademicDegree, new Dictionary<string, object> { { "class", "form-control input-sm" } })
                    }


                </div>
            }

        </div>
    </div>
    <div class="bpanel-footer text-right">
        <a href="#" onclick=" saverequest()" class=" btn btn-primary btn-labeled"><span class="btn-label icon fa fa-save"></span>ذخیره</a>
    </div>
</div>



<div id="dlgAttach" class="easyui-dialog" modal="true" style="width: 800px; height: 450px;"
     closed="true">
</div>


<div id="dlgListAttach" class="easyui-dialog" modal="true" style="width: 800px; height: 450px;"
     closed="true">
</div>

<div class="bpanel">       
        <div class="note note-primary">اطلاعات تکمیلی</div>

    @using (Html.BeginForm("CreateFurtherInformation", "Request", FormMethod.Post, new { id = "addFurtherInformationForm", enctype = "multipart/form-data" }))
    {
        @Html.TextBox("FurtherInformation.RequestId", Model.Request == null ? 0 : Model.Request.Id, new { hidden = "hidden", id = "FurtherInformation_RequestId" })
        @Html.TextBoxFor(model => model.FurtherInformation.Id, new { hidden = "hidden" })
        <div class="bpanel-body">
            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.HasExecutivePosts)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>پست اجرایی</lable>
                </div>
                <div class="col-md-6">
                    @Html.TextBoxFor(model => model.FurtherInformation.ExecutivePostName, new { @class = "form-control input-sm", disabled = "disabled", style = "max-width:none" })
                </div>
            </div>
            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.OfficersStudyPhD)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>مامور به تحصیل در مقطع دکتری</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (پیوست)
                        <input type="file" name="OfficersStudyPhDUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="OfficersStudyPhDUpload">
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.TypeOfPartTimeWorkNoconnectionOtherUniversity)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>نوع همکاری نیمه وقت بدون هیچگونه ارتباط با سایر دانشگاهها</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (پیوست)
                        <input type="file" name="TypeOfPartTimeWorkNoconnectionOtherUniversityUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="TypeOfPartTimeWorkNoconnectionOtherUniversityUpload">
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.TypeOfPartTimeButEmployeesOtherUniversity)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>نوع همکاری نیمه وقت اما به صورت تمام وقت شاغل در سایر دانشگاهها</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (حکم کارگزینی)(پیوست)
                        <input type="file" name="TypeOfPartTimeButEmployeesOtherUniversityUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="TypeOfPartTimeButEmployeesOtherUniversityUpload">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.TypeOfFullTimeButRetired)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>نوع همکاری تمام وقت اما بازنشسته از سایر دانشگاهها</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (پیوست)
                        <input type="file" name="TypeOfFullTimeButRetiredUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="TypeOfFullTimeButRetiredUpload">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.TypeOfFullTimeButNoRetired)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>نوع همکاری تمام وقت اما غیر بازنشسته در صورت استفاء</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (پیوست)
                        <input type="file" name="TypeOfFullTimeButNoRetiredUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="TypeOfFullTimeButNoRetiredUpload">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.GraduationDaneshvari)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>اخذ مدرک دانشوری با استفاده از آیین نامه طرح دانشوری دانشگاه</lable>
                </div>
            </div>


            <div class="bpanel panel-transparent">
                <div class="panel-heading" style="margin-bottom: 5px">
                    <span class="panel-title">سهمیه ایثارگران</span>
                    <div class="panel-heading-controls">
                        <div class="panel-heading-icon"><i class="fa fa-inbox"></i></div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-1">
                        <div class="switcher switcher-theme-square ">
                            @Html.CheckBoxFor(model => model.FurtherInformation.FreedmanOrCaptive)
                        </div>
                    </div>
                    <div class="col-md-5">
                        <lable>آزادگان،اسرا،مفقودین</lable>
                    </div>
                    <div class="col-md-6">
                        @Html.EnumDropDownListFor(p => p.FurtherInformation.FreedmanOrCaptiveType, new Dictionary<string, object> { { "class", "form-control input-sm" } })
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-1">
                        <div class="switcher switcher-theme-square ">
                            @Html.CheckBoxFor(model => model.FurtherInformation.IsVeteran)
                        </div>
                    </div>
                    <div class="col-md-5">
                        <lable>جانباز</lable>
                    </div>
                    <div class="col-md-6">
                        @Html.EnumDropDownListFor(p => p.FurtherInformation.VeteranType, new Dictionary<string, object> { { "class", "form-control input-sm" } })
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-1">
                        <div class="switcher switcher-theme-square ">
                            @Html.CheckBoxFor(model => model.FurtherInformation.Fighter)
                        </div>
                    </div>
                    <div class="col-md-5">
                        <lable>رزمنده</lable>
                    </div>
                    <div class="col-md-6">
                        @Html.EnumDropDownListFor(p => p.FurtherInformation.FighterType, new Dictionary<string, object> { { "class", "form-control input-sm" } })
                    </div>
                </div>
            </div>


            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.HasPhDNoOfficersStudy)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>دارای دکترای تخصصی غیر مامور به تحصیل</lable>
                </div>
            </div>

            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.HasMaternityLeave)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>دارای مرخصی استعلاجی زایمان</lable>
                </div>
            </div>

            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.HasPhDIncludingMilitary)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>استفاده از طرح مشمولین متخصص دوره دکتری تخصصی</lable>
                </div>
            </div>




            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.PassPhDPassa)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>گذراندن دوره پسا دکتری</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (پیوست)
                        <input type="file" name="PassPhDPassaUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="PassPhDPassaUpload">
                    </div>
                </div>
            </div>


            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.TakingSabbatical)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>درحال گذراندن فرصت مطالعاتی</lable>
                </div>
                <div class="col-md-6">
                    <div class="form-inline">
                        (پیوست)
                        <input type="file" name="TakingSabbaticalUpload" multiple="multiple" disabled="disabled" class="form-control input-sm" id="TakingSabbaticalUpload">
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-1">
                    <div class="switcher switcher-theme-square ">
                        @Html.CheckBoxFor(model => model.FurtherInformation.HasBasicDelayedPreviousYears)
                    </div>
                </div>
                <div class="col-md-5">
                    <lable>دارای  مطالبه پایه معوق</lable>
                </div>
            </div>

        </div>
    }

    <div class="bpanel-footer" style="text-align: left">
 <a href="#" onclick=" addFurtherInformation()" class=" btn btn-primary btn-labeled" ><span class="btn-label icon fa fa-save"></span>ذخیره</a>
    </div>
</div>


<div class="bpanel">
    <div class="note note-primary">فعالیت های آموزشی</div>

    <div class="bpanel-body">
        <table id="dgEducation"></table>
    </div>
    <div class="note note-primary">فعالیت های پژوهشی</div>
    <div class="alert">
        <strong>اخطار!</strong> در صورت عدم ارائه مستندات پژوهشی اعلام شده کمیته ترفیعات از بررسی آن امتناع خواهد کرد
    </div>
    <div class="bpanel-body">
        <table id="dgReasearch"></table>
    </div>
    <div class="note note-primary">راهنمایی پروژه ، پایان نامه ، و رساله دانشجویی خاتمه یافته</div>
    <div class="bpanel-body">
        <table id="dgDissertation"></table>
    </div>
    <div class="note note-primary">
        فعالیت های پژوهشی - فناوری 
    </div>
    <div class="bpanel-body">
        <table id="dgTechnology"></table>
    </div>

   
        <div class="note note-primary">
            فعالیت های علمی - اجرایی</div>
      
    <div class="bpanel-body">
        <table id="dgScientificExecutive"></table>
    </div>
</div>





<!-- Colors -->
@section scripts{

    @Scripts.Render("~/bundles/jqueryAjaxForm")
    <script src="~/Content/jquery-easyui-1.4.2/edatagrid.js"></script>

    <script>

        $('#addRequestForm').ajaxForm();
        $('#addFurtherInformationForm').ajaxForm();
      

        $(function() {
            $('.switcher :input[type=checkbox]').each(function() {
                $(this).switcher({
                    theme: 'square',
                    on_state_content: '<span class="fa fa-check"></span>',
                    off_state_content: '<span class="fa fa-times"></span>'
                });

                $(this).on('change', function() {
                    if ($(this).attr("id") == 'FurtherInformation_HasExecutivePosts') {
                        if ($(this).is(':checked')) {
                            $('#FurtherInformation_ExecutivePostName').removeAttr('disabled');
                        } else {
                            $('#FurtherInformation_ExecutivePostName').attr('disabled', 'disabled');
                        }

                    } else if (($(this).attr("id") == 'FurtherInformation_OfficersStudyPhD')) {
                        if ($(this).is(':checked')) {
                            $('#OfficersStudyPhDUpload').removeAttr('disabled');
                        } else {
                            $('#OfficersStudyPhDUpload').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_TypeOfPartTimeButEmployeesOtherUniversity')) {
                        if ($(this).is(':checked')) {
                            $('#TypeOfPartTimeButEmployeesOtherUniversityUpload').removeAttr('disabled');
                        } else {
                            $('#TypeOfPartTimeButEmployeesOtherUniversityUpload').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_TypeOfFullTimeButRetired')) {
                        if ($(this).is(':checked')) {
                            $('#TypeOfFullTimeButRetiredUpload').removeAttr('disabled');
                        } else {
                            $('#TypeOfFullTimeButRetiredUpload').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_TypeOfFullTimeButNoRetired')) {
                        if ($(this).is(':checked')) {
                            $('#TypeOfFullTimeButNoRetiredUpload').removeAttr('disabled');
                        } else {
                            $('#TypeOfFullTimeButNoRetiredUpload').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_Fighter')) {
                        if ($(this).is(':checked')) {
                            $('#FurtherInformation_FighterType').removeAttr('disabled');
                        } else {
                            $('#FurtherInformation_FighterType').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_FreedmanOrCaptive')) {
                        if ($(this).is(':checked')) {
                            $('#FurtherInformation_FreedmanOrCaptiveType').removeAttr('disabled');
                        } else {
                            $('#FurtherInformation_FreedmanOrCaptiveType').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_PassPhDPassa')) {
                        if ($(this).is(':checked')) {
                            $('#PassPhDPassaUpload').removeAttr('disabled');
                        } else {
                            $('#PassPhDPassaUpload').attr('disabled', 'disabled');
                        }
                    } else if (($(this).attr("id") == 'FurtherInformation_TakingSabbatical')) {
                        if ($(this).is(':checked')) {
                            $('#TakingSabbaticalUpload').removeAttr('disabled');
                        } else {
                            $('#TakingSabbaticalUpload').attr('disabled', 'disabled');
                        }
                    }
                    updateDisplay();
                });

            })
        });

        var indexEditing = null;
        $('#dgEducation').edatagrid({
            toolbar:
            [
                {
                    text: 'جدید',
                    iconCls: 'icon-add',
                    handler: function () {
                        $('#dgEducation').edatagrid('addRow');
                    }
                }, '-',
                {
                    text: 'حذف',
                    iconCls: 'icon-remove',
                    handler: function () {
                        $('#dgEducation').edatagrid('destroyRow');
                    }
                }, '-',
                {
                    text: 'ذخیره',
                    iconCls: 'icon-save',
                    handler: function () {
                        $('#dgEducation').edatagrid('saveRow');
                    }
                }, '-',
                {
                    text: 'انصراف',
                    iconCls: 'icon-undo',
                    handler: function () {
                        $('#dgEducation').edatagrid('cancelRow');
                    }
                }
            ],
            idField: 'Id',
            loadMsg: 'شکیبا باشید...',
            rownumbers: true,
            height: 200,
            singleSelect: 'true',

            url: '@Url.Action("GetEducation", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            saveUrl: '@Url.Action("CreateEducationReasearch", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            updateUrl: '@Url.Action("EditEducationReasearch", "Request")',
            destroyUrl: '@Url.Action("DeleteEducationReasearch", "Request")',
            onError: function (index, row) {
                alert('error');
            },
            columns: [
                [
                    {
                        field: 'EducationalResearchStatus',
                        title: 'نوع',
                        value: 1,
                        hidden: 'hidden',
                        width: 80,
                        editor: { type: 'textbox', width: 200, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'Term',
                        title: 'نیمسال',
                        width: 80,
                        editor: {
                            type: 'combobox',
                            options: {
                                valueField: 'TermId',
                                textField: 'Term',
                                method: 'get',
                                url: '@Url.Action("GetTerm", "Request")'
                            }
                        }
                    },
                    {
                        field: 'Subject',
                        title: 'عنوان درس',
                        width: 300,
                        editor: { type: 'validatebox', width: 200, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'CourseNo',
                        title: 'شماره درس',
                        width: 100,
                        editor: {
                            type: 'numberspinner',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'UnitCount',
                        autoRowHeight: true,
                        title: 'تعداد واحد',
                        width: 100,
                        editor: { type: 'numberspinner', width: 100, options: { required: true } }
                    },
                    {
                        field: 'GradeEducation',
                        autoRowHeight: true,
                        title: 'مقطع',
                        width: 200,
                        hidden: "hidden",
                        editor: {
                            type: 'combobox',
                            options: {
                                valueField: 'GradeEducationId',
                                textField: 'GradeEducation',
                                method: 'get',
                                url: '@Url.Action("GetGradeEducation", "Request")'
                            }
                        }
                    },
                    {
                        field: 'StudentCount',
                        autoRowHeight: true,
                        title: 'تعداد دانشجو',
                        width: 200,
                        editor: { type: 'numberspinner', width: 100, options: { required: true } }
                    }
                ]
            ],
            onBeginEdit: function (index, row) {
                var ed = $('#dgEducation').edatagrid('getEditor',
                { index: index, field: 'EducationalResearchStatus' });
                $(ed.target).textbox('setValue', 1);
            }
        });


        $('#dgReasearch').edatagrid({
            toolbar:
            [
                {
                    text: 'جدید',
                    datatoggle: 'bbt',
                    iconCls: 'icon-add',
                    handler: function () {
                        $('#dgReasearch').edatagrid('addRow');
                    }
                }, '-',
                {
                    text: 'حذف',
                    iconCls: 'icon-remove',
                    handler: function () {
                        $('#dgReasearch').edatagrid('destroyRow');
                    }
                }, '-',
                {
                    text: 'ذخیره',
                    iconCls: 'icon-save',
                    handler: function () {
                        $('#dgReasearch').edatagrid('saveRow');
                    }
                }, '-',
                {
                    text: 'انصراف',
                    iconCls: 'icon-undo',
                    handler: function () {
                        $('#dgReasearch').edatagrid('cancelRow');
                    }
                }, '-',
                {
                    text: 'پیوست',
                    iconCls: 'pic_attach1',
                    handler: function () {
                        showAddAttachForm();
                        $('#dlgAttach').dialog('center');
                    }
                }
            ],
            idField: 'Id',
            loadMsg: 'شکیبا باشید...',
            rownumbers: true,
            height: 200,
            singleSelect: 'true',

            url: '@Url.Action("GetResearch", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            saveUrl: '@Url.Action("CreateEducationReasearch", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            updateUrl: '@Url.Action("EditEducationReasearch", "Request")',
            destroyUrl: '@Url.Action("DeleteEducationReasearch", "Request")',
            onError: function (index, row) {
                alert('error');
            },
            columns: [
                [
                    {
                        field: 'EducationalResearchStatus',
                        title: 'نوع',
                        value: 1,
                        hidden: 'hidden',
                        width: 80,
                        editor: { type: 'textbox', width: 200, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'Term',
                        title: 'نیمسال',
                        width: 80,
                        editor: {
                            type: 'combobox',
                            options: {
                                valueField: 'TermId',
                                textField: 'Term',
                                method: 'get',
                                url: '@Url.Action("GetTerm", "Request")'
                            }
                        }
                    },
                    {
                        field: 'Subject',
                        title: 'عنوان طرح پژوهشی',
                        width: 300,
                        editor: { type: 'validatebox', width: 200, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'ResearchPost',
                        autoRowHeight: true,
                        title: 'سمت در طرح',
                        width: 100,
                        editor: {
                            type: 'combobox',
                            options: {
                                valueField: 'PostPlanId',
                                textField: 'PostPlan',
                                method: 'get',
                                url: '@Url.Action("GetPostPlan", "Request")'
                            }
                        }
                    },
                    {
                        field: 'BeginDate',
                        autoRowHeight: true,
                        title: 'تاریخ شروع',
                        width: 100,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'EndDate',
                        autoRowHeight: true,
                        title: 'تاریخ خاتمه',
                        width: 100,
                        editor: { type: 'textbox', width: 100, options: { required: true } }
                    },
                    {
                        field: 'StudentCount',
                        autoRowHeight: true,
                        title: 'تعداد دانشجو',
                        width: 100,
                        editor: { type: 'numberspinner', width: 100, options: { required: true } }
                    },
                    {
                        field: 'Attach',
                        title: 'نمایش پیوست ها',
                        width: 100,
                        formatter: function (value, rows, index) {
                            return '<a researchId=' + rows.Id + ' href="javascript:void(0)" ' +
                                ' onclick="showListAttachForm(this)"><span class="fa fa-paperclip fa-2x"></span></a>&nbsp&nbsp&nbsp';
                        }
                    }
                ]
            ],
            onBeginEdit: function (index, row) {
                var ed = $('#dgReasearch').edatagrid('getEditor',
                { index: index, field: 'EducationalResearchStatus' });
                $(ed.target).textbox('setValue', 2);
            }
        });


        $('#dgScientificExecutive').edatagrid({
            toolbar:
            [
                {
                    text: 'جدید',
                    datatoggle: 'bbt',
                    iconCls: 'icon-add',
                    handler: function () {
                        $('#dgScientificExecutive').edatagrid('addRow');
                    }
                }, '-',
                {
                    text: 'حذف',
                    iconCls: 'icon-remove',
                    handler: function () {
                        $('#dgScientificExecutive').edatagrid('destroyRow');
                    }
                }, '-',
                {
                    text: 'ذخیره',
                    iconCls: 'icon-save',
                    handler: function () {
                        $('#dgScientificExecutive').edatagrid('saveRow');
                    }
                }, '-',
                {
                    text: 'انصراف',
                    iconCls: 'icon-undo',
                    handler: function () {
                        $('#dgScientificExecutive').edatagrid('cancelRow');
                    }
                }
            ],
            idField: 'Id',
            loadMsg: 'شکیبا باشید...',
            rownumbers: true,
            height: 200,
            singleSelect: 'true',

            url: '@Url.Action("GetScientificExecutive", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            saveUrl: '@Url.Action("CreateScientificExecutive", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            updateUrl: '@Url.Action("EditEducationReasearch", "Request")',
            destroyUrl: '@Url.Action("DeleteScientificExecutive", "Request")',
            onError: function (index, row) {
                alert('error');
            },
            columns: [
                [
                    {
                        field: 'Subject',
                        title: 'عنوان',
                        width: 400,
                        editor: { type: 'validatebox', width: 200, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'LengthOfService',
                        autoRowHeight: true,
                        title: 'مدت خدمت',
                        width: 100,
                        editor: {
                            type: 'numberspinner',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'TimeHalfYear',
                        autoRowHeight: true,
                        title: 'ساعات حضور در نیمسال',
                        width: 150,
                        editor: {
                            type: 'numberspinner',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    }
                ]
            ]
        });


        $('#dgDissertation').edatagrid({
            toolbar:
            [
                {
                    text: 'جدید',
                    datatoggle: 'bbt',
                    iconCls: 'icon-add',
                    handler: function () {
                        $('#dgDissertation').edatagrid('addRow');
                    }
                }, '-',
                {
                    text: 'حذف',
                    iconCls: 'icon-remove',
                    handler: function () {
                        $('#dgDissertation').edatagrid('destroyRow');
                    }
                }, '-',
                {
                    text: 'ذخیره',
                    iconCls: 'icon-save',
                    handler: function () {
                        $('#dgDissertation').edatagrid('saveRow');
                    }
                }, '-',
                {
                    text: 'انصراف',
                    iconCls: 'icon-undo',
                    handler: function () {
                        $('#dgDissertation').edatagrid('cancelRow');
                    }
                }
            ],
            idField: 'Id',
            loadMsg: 'شکیبا باشید...',
            rownumbers: true,
            height: 200,
            singleSelect: 'true',

            url: '@Url.Action("GetDissertation", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            saveUrl: '@Url.Action("CreateDissertation", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            updateUrl: '@Url.Action("EditEducationReasearch", "Request")',
            destroyUrl: '@Url.Action("DeleteDissertation", "Request")',
            onError: function (index, row) {
                alert('error');
            },
            columns: [
                [
                    {
                        field: 'Subject',
                        title: 'عنوان پروژه،پایان نامه،و رساله',
                        width: 350,
                        editor: { type: 'textbox', width: 300, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'StudentName',
                        autoRowHeight: true,
                        title: 'نام دانشجو',
                        width: 200,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'GradeEducation',
                        title: 'مقطع',
                        width: 80,
                        editor: {
                            type: 'combobox',
                            options: {
                                required: true,
                                valueField: 'GradeEducationId',
                                textField: 'GradeEducation',
                                method: 'get',
                                url: '@Url.Action("GetGradeEducation", "Request")'
                            }
                        }
                    },
                    {
                        field: 'BeginDate',
                        autoRowHeight: true,
                        title: 'تاریخ شروع',
                        width: 80,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'VindicationDate',
                        autoRowHeight: true,
                        title: 'تاریخ دفاع',
                        width: 80,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'UnitCount',
                        autoRowHeight: true,
                        title: 'تعداد واحد',
                        width: 60,
                        editor: {
                            type: 'numberspinner',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    }
                ]
            ]
        });


        $('#dgTechnology').edatagrid({
            toolbar:
            [
                {
                    text: 'جدید',
                    datatoggle: 'bbt',
                    iconCls: 'icon-add',
                    handler: function () {
                        $('#dgTechnology').edatagrid('addRow');
                    }
                }, '-',
                {
                    text: 'حذف',
                    iconCls: 'icon-remove',
                    handler: function () {
                        $('#dgTechnology').edatagrid('destroyRow');
                    }
                }, '-',
                {
                    text: 'ذخیره',
                    iconCls: 'icon-save',
                    handler: function () {
                        $('#dgTechnology').edatagrid('saveRow');
                    }
                }, '-',
                {
                    text: 'انصراف',
                    iconCls: 'icon-undo',
                    handler: function () {
                        $('#dgTechnology').edatagrid('cancelRow');
                    }
                }
            ],
            idField: 'Id',
            loadMsg: 'شکیبا باشید...',
            rownumbers: true,
            height: 200,
            singleSelect: 'true',

            url: '@Url.Action("GetTechnologies", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            saveUrl: '@Url.Action("CreateTechnology", "Request", new {requestId = Model.Request == null ? 0 : Model.Request.Id})',
            updateUrl: '@Url.Action("EditEducationReasearch", "Request")',
            destroyUrl: '@Url.Action("DeleteTechnology", "Request")',
            onError: function (index, row) {
                alert('error');
            },
            columns: [
                [
                    {
                        field: 'TechnologyType',
                        title: 'نوع فعالیت',
                        width: 120,
                        editor: {
                            type: 'combobox',
                            options: {
                                required: true,
                                valueField: 'TechnologyTypeId',
                                textField: 'TechnologyType',
                                method: 'get',
                                url: '@Url.Action("GetTechnologyType", "Request")'
                            }
                        }
                    },
                    {
                        field: 'Subject',
                        title: 'عنوان',
                        width: 350,
                        editor: { type: 'textbox', width: 300, autoRowHeight: true, options: { required: true } }
                    },
                    {
                        field: 'PresentationDate',
                        autoRowHeight: true,
                        title: 'تاریخ انتشار/ارائه',
                        width: 100,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true,
                                prompt:'----/--/--'
                            }
                        }
                    },
                    {
                        field: 'PlacePresentation',
                        autoRowHeight: true,
                        title: 'محل انتشار/ارائه',
                        width: 130,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    },
                    {
                        field: 'PartnersNames',
                        autoRowHeight: true,
                        title: 'اسامی همکاران',
                        width: 200,
                        editor: {
                            type: 'textbox',
                            width: 100,
                            options: {
                                required: true
                            }
                        }
                    }
                ]
            ]
        });

        $('a').btooltip({ placement: 'top' });

        function saverequest() {
            if ($('#addRequestForm').valid()) {
                $('#addRequestForm').ajaxSubmit({
                    cashe: false,
                    url: '@Url.Action("Create", "Request", new {area = "UserArea"}, "http")',
                    type: 'Post',
                    dataType: 'json',
                    data: $('#addRequestForm').serialize(),
                    success: function (result) {
                        $('a.l-btn').linkbutton({ disabled: false });
                        $.messager.show({
                            title: 'پیام سیستم',
                            msg: result.Msg,
                            showType: 'show'
                        });
                    },
                    error: function (xhr, status) {
                        xhr.responseText();
                    }
                });
            } else {
                return $(this).form('validate');
            }
        }


        function addFurtherInformation() {
            if ($('#addFurtherInformationForm').valid()) {
                $('#addFurtherInformationForm').ajaxSubmit({
                    url: '@Url.Action("CreateFurtherInformation", "Request", new {area = "UserArea"}, "http")',
                    type: 'Post',
                    dataType: 'json',
                    data: $('#addFurtherInformationForm').serialize(),
                    success: function (result) {
                        $('#FurtherInformation_Id').val(result.FurtherInformationId);
                        $.messager.show({
                            title: 'پیام سیستم',
                            msg: result.Msg,
                            showType: 'show'
                        });
                    },
                    error: function (xhr, status) {
                        xhr.responseText();
                    }
                });
            } else {
                return $(this).form('validate');
            }
        }

        if ('@Model.Empty' == 'True')
            $('a.l-btn').linkbutton({ disabled: true });


        function showAddAttachForm() {
            var dgselected = $('#dgReasearch').edatagrid('getSelected');
            if (dgselected == null) {
                $.messager.alert('Warning', 'رکوردی انتخاب نشده است!');
                return;
            }
            $.ajax({
                url: '@Url.Action("UploadAttachReasearch", "Request", new {area = "UserArea"})',
                dataType: 'html',
                data: { reaserchId: dgselected.Id },
                type: 'get',
                success: function (result) {
                    $('#dlgAttach').html(result);
                    $('#dlgAttach').dialog('open').dialog('setTitle', 'افزودن پیوست ها');
                },
                error: function () {

                }
            });
        }


        function showListAttachForm(element) {
            $.ajax({
                url: '@Url.Action("ListReaserchAttachForm", "Request", new {area = "UserArea"})',
                dataType: 'html',
                data: { researchId: $(element).attr('researchId') },
                type: 'get',
                success: function (result) {
                    $('#dlgListAttach').html(result);
                    $('#dlgListAttach').dialog('open').dialog('setTitle', 'لیست پیوست ها');
                    $('#dlgListAttach').dialog('center');
                },
                error: function () {

                }
            });
        }


    </script>
}



